import Axios from 'axios';
// import vm from "../main"
import store from "../store"
const ConfigBaseURL = "/";
//
const Service = Axios.create({
    baseURL: ConfigBaseURL,
    timeout: 8000,
});

Service.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";

Service.interceptors.request.use(
    config => {
        // console.log('请求拦截');
        // store.dispatch("disLoading");
        // if (store.getters.token) {
        // config.headers["token"] = store.getters.token
        // }
        return config;
    });

Service.interceptors.response.use(res => {
    // console.log('响应拦截');
    // store.dispatch("hideLoading");
    // if (res.data.token) {
    //     store.dispatch("setToken", res.data.token)
    // }
    return res;
},
    error => {
        const msg = error.Message !== undefined ? error.message : '';
        Message({
            message: "网络错误" + msg,
            type: 'error',
            duration: 3 * 1000
        });
        loadingInstance.close();
        return Pormise.reject(error);
    }
);

export default
    Service; // 调用者 ---> ../service/index.js --> getList